/*
https://leetcode.cn/problems/house-robber/
198. 打家劫舍
medium, 彭珵 2024.9.3
*/

class Solution {
public:
    int rob(vector<int>& nums) {
        int prev1 = 0, prev2 = 0; 
        for (int num : nums) {
            int temp = prev1; 
            prev1 = max(prev1, prev2 + num); 
            prev2 = temp; 
        }
        return prev1; 
    }
};